package com.atguigu.spxz.product.controller;

import com.atguigu.spxz.product.service.CategoryService;
import com.atguigu.spzx.model.entity.product.Category;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "首页分类管理")
@RestController
@RequestMapping(value="/api/product/category/")
public class CategoryController {

    @Autowired
    CategoryService categoryService;


    @Operation(summary = "查询商品分类列表")
    @GetMapping("findCategoryTree")
    public Result findCategoryTree(){

      List<Category> categoryList =  categoryService.findCategoryTree();

      return Result.build(categoryList, ResultCodeEnum.SUCCESS);

    }
}
